incorrectInput = True
while incorrectInput:
    dataList = input("输入鸡兔的头数和腿数，用空格隔开\n").split(" ")
    if len(dataList) != 2:
        print("输入格式错误")
        continue

    numOfHead, numOfLeg = dataList
    if numOfHead.isdigit() and numOfLeg.isdigit():
        numOfHead = int(numOfHead)
        numOfLeg = int(numOfLeg)
        if numOfHead < 0 and numOfLeg < 0:
            print("输入数据错误，请输入两个非负整数")
        else:    
            incorrectInput = False
    else:
        print("输入数据错误，请输入两个非负整数")
        
solution = False
for numOfChicken in range(numOfHead + 1):
    numOfRabbit = numOfHead - numOfChicken
    if numOfChicken * 2 + numOfRabbit * 4 == numOfLeg:
        print("鸡{}只，兔{}只".format(numOfChicken, numOfRabbit))
        solution = True
        break

if not(solution):
    print("无解")
